home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 5 / MacMania 5.toast / / Internet software / NewsWatcher / NW Source / Source / dummy.c < prev    next >
Text File  |  1997-01-09  |  8KB  |  301 lines

  1. /*----------------------------------------------------------------------------
  2.  
  3.     dummy.c
  4.  
  5.     This module handles the "dummy" window. This window is a hack used
  6.     with the Next Article and Next Thread commands to keep the subject
  7.     window from flickering between the active and inactive states. It
  8.     is always off-screen, and is normally hidden. The dummy window is 
  9.     also used during printing to set the print job name.
  10.     
  11.     Copyright © 1994-1997, Northwestern University.
  12.  
  13. ----------------------------------------------------------------------------*/
  14.  
  15. #include "glob.h"
  16. #include "dummy.h"
  17. #include "windutil.h"
  18. #include "memutil.h"
  19.  
  20.  
  21.  
  22. static WindowPtr gDummyWindow = nil;
  23.  
  24.  
  25.  
  26. /*----------------------------------------------------------------------------
  27.     ShowDummyWindow 
  28.     
  29.     Show the dummy window. Create it if it doesn't already exist.
  30.     
  31.     Exit:    function result = window kind.
  32.     
  33.     The dummy window is an empty off-screen window of kind kDummy.
  34.     It is normally hidden and not used for anything. It is temporarily
  35.     brought to the front and shown by the Next Article and Next Thread 
  36.     commands as a hack to avoid activating the subject window during these 
  37.     operations. This avoids having the selected item in the subject window
  38.     flicker between the active and inactive highlighting styles, which is
  39.     annoying.
  40. ----------------------------------------------------------------------------*/
  41.  
  42. OSErr ShowDummyWindow (void)
  43. {
  44.     Rect bounds;
  45.     OSErr err = noErr;
  46.     TWindow **info = nil;
  47.  
  48.     if (gDummyWindow == nil) {
  49.         SetRect(&bounds, -0x7010, -0x7010, -0x7000, -0x7000);
  50.         err = MyNewWindow(&bounds, "\p", false, documentProc, (WindowPtr)-1,
  51.             false, 0, &gDummyWindow);
  52.         if (err != noErr) goto exit;
  53.         err = MyNewHandle(sizeof(TWindow), &info);
  54.         if (err != noErr) goto exit;        
  55.         (**info).kind = kDummy;
  56.         SetWRefCon(gDummyWindow, (long)info);
  57.     }
  58.     ShowWindow(gDummyWindow);
  59.     SelectWindow(gDummyWindow);
  60.     return noErr;
  61.     
  62. exit:
  63.  
  64.     MyDisposeWindow(gDummyWindow);
  65.     gDummyWindow = nil;
  66.     MyDisposeHandle(info);
  67.     return err;
  68. }
  69.  
  70.  
  71.  
  72. /*----------------------------------------------------------------------------
  73.     HideDummyWindow 
  74.     
  75.     Hide the dummy window.
  76. ----------------------------------------------------------------------------*/
  77.  
  78. void HideDummyWindow (void) {
  79.     if (gDummyWindow != nil) HideWindow(gDummyWindow);
  80. }
  81.  
  82.  
  83.  
  84. /*----------------------------------------------------------------------------
  85.     Activate 
  86.     
  87.     Handle an activate event for the dummy window.
  88.             
  89.     Entry:    wind = pointer to dummy window.
  90.             act = true to activate, false to deactivate
  91. ----------------------------------------------------------------------------*/
  92.  
  93. static void Activate (WindowPtr wind, Boolean act)
  94. {
  95. }
  96.  
  97.  
  98.  
  99. /*----------------------------------------------------------------------------
  100.     Update 
  101.     
  102.     Handle an update event for the dummy window.
  103.             
  104.     Entry:    wind = pointer to dummy window.
  105. ----------------------------------------------------------------------------*/
  106.  
  107. static void Update (WindowPtr wind)
  108. {
  109. }
  110.  
  111.  
  112.  
  113. /*----------------------------------------------------------------------------
  114.     Mouse 
  115.     
  116.     Handle a mouse down event in the content area of the dummy window.
  117.             
  118.     Entry:    wind = pointer to dummy window.
  119.             where = location of mouse down in local coords.
  120.             modifiers = modifiers field from event record.
  121.             
  122.     Exit:    function result = error code.
  123. ----------------------------------------------------------------------------*/
  124.  
  125. static OSErr Mouse (WindowPtr wind, Point where, short modifiers)
  126. {
  127.      return noErr;
  128. }
  129.  
  130.  
  131.  
  132. /*----------------------------------------------------------------------------
  133.     Draggable
  134.     
  135.     Determine whether a mouse down event is on a draggable object in the 
  136.     dummy window.
  137.     
  138.     Entry:    wind = pointer to dummy window.
  139.             where = location of mouse down event, in local coordinates.
  140.             modifiers = modifiers field from event record.
  141.             
  142.     Exit:    function result = true if object is draggable.
  143. ----------------------------------------------------------------------------*/
  144.  
  145. static Boolean Draggable (WindowPtr wind, Point where, short modifiers)
  146. {
  147.     return false;
  148. }
  149.  
  150.  
  151.  
  152. /*----------------------------------------------------------------------------
  153.     Key 
  154.     
  155.     Handle a key down event for the dummy window.
  156.             
  157.     Entry:    wind = pointer to dummy window.
  158.             theChar = ASCII code of key.
  159.             theKey = keyboard code of key.
  160.             modifiers = modifiers field from event record.
  161.             
  162.     Exit:    function result = error code.
  163. ----------------------------------------------------------------------------*/
  164.  
  165. static OSErr Key (WindowPtr wind, unsigned char theChar, unsigned char theKey, 
  166.     short modifiers)
  167. {
  168.     return noErr;
  169. }
  170.  
  171.  
  172.  
  173. /*----------------------------------------------------------------------------
  174.     Grow 
  175.     
  176.     Handle a mouse down event in the grow box of the dummy window.
  177.     
  178.     Entry:    wind = pointer to dummy window.
  179.             where = location of mouse down event, in global coordinates.
  180.             
  181.     Exit:    function result = error code.
  182. ----------------------------------------------------------------------------*/
  183.  
  184. static OSErr Grow (WindowPtr wind, Point where)
  185. {
  186.     return noErr;
  187. }
  188.  
  189.  
  190.  
  191. /*----------------------------------------------------------------------------
  192.     Zoom
  193.     
  194.     Zoom the dummy window.
  195.     
  196.     Entry:    wind = pointer to dummy window.
  197.             zoomDir = zoom direction = inZoomIn or inZoomOut.
  198.             
  199.     Exit:    function result = error code.
  200. ----------------------------------------------------------------------------*/
  201.  
  202. static OSErr Zoom (WindowPtr wind, short zoomDir)
  203. {
  204.     return noErr;
  205. }
  206.  
  207.  
  208.  
  209. /*----------------------------------------------------------------------------
  210.     Command 
  211.     
  212.     Handle a command for the dummy window.
  213.             
  214.     Entry:    wind = pointer to dummy window.
  215.             menu = the menu.
  216.             item = the item.
  217.             modifiers = modifiers field from event record.
  218.     
  219.     Exit:    function result = error code.
  220. ----------------------------------------------------------------------------*/
  221.  
  222. static OSErr Command (WindowPtr wind, short menu, short item, short modifiers)
  223. {
  224.      return noErr;
  225. }
  226.  
  227.  
  228.  
  229. /*----------------------------------------------------------------------------
  230.     Close 
  231.     
  232.     Close the dummy window.
  233.             
  234.     Entry:    wind = pointer to dummy window.
  235.     
  236.     Exit:    function result = error code.
  237. ----------------------------------------------------------------------------*/
  238.  
  239. static OSErr Close (WindowPtr wind)
  240. {
  241.     return noErr;
  242. }
  243.  
  244.  
  245.  
  246. /*----------------------------------------------------------------------------
  247.     Help 
  248.     
  249.     Handle help balloons for a dummy window.
  250.             
  251.     Entry:    wind = pointer to dummy window.
  252.             where = current mouse location in local coordinates.
  253. ----------------------------------------------------------------------------*/
  254.  
  255. static void Help (WindowPtr wind, Point where)
  256. {
  257. }
  258.  
  259.  
  260.  
  261. /*----------------------------------------------------------------------------
  262.     Idle 
  263.     
  264.     Handle idle time tasks for the dummy window.
  265.             
  266.     Entry:    wind = pointer to dummy window.
  267.     
  268.     Exit:    cursorRgn = cursor region for WaitNextEvent mouse moved events.
  269. ----------------------------------------------------------------------------*/
  270.  
  271. static void Idle (WindowPtr wind, RgnHandle cursorRgn)
  272. {
  273. }
  274.  
  275.  
  276.  
  277. /*----------------------------------------------------------------------------
  278.     InitDummyDispatchTable 
  279.     
  280.     Initialize the dispatch table for the dummy window.
  281. ----------------------------------------------------------------------------*/
  282.  
  283. void InitDummyDispatchTable (void)
  284. {
  285.     TDispatch *d;
  286.     
  287.     d = &gDispatch[kDummy];
  288.     
  289.     d->activate = Activate;
  290.     d->update = Update;
  291.     d->mouse = Mouse;
  292.     d->draggable = Draggable;
  293.     d->key = Key;
  294.     d->grow = Grow;
  295.     d->zoom = Zoom;
  296.     d->command = Command;
  297.     d->close = Close;
  298.     d->idle = Idle;
  299.     d->help = Help;
  300. }
  301.